package com.cms.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Copyright (c) Since 2024 ThinkCms - All Rights Reserved
 *
 * @author what
 * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
 * @Date 2024/10/31 11:13
 */

@Configuration("1234")
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private HookHtmlInterceptor hookInterceptor;
    @Autowired
    private ApiInterceptor apiInterceptor;
    @Autowired
    private WebInterceptor webInterceptor;

    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(hookInterceptor).addPathPatterns("/admin/**", "/web/**", "/plugins/**").excludePathPatterns("/api/**");
        registry.addInterceptor(webInterceptor).addPathPatterns("/admin/**","/plugins/**/admin/**").excludePathPatterns("/admin/login", "/admin/login/act", "/api/**","/plugins/**/api/**");
        registry.addInterceptor(apiInterceptor).addPathPatterns("/api/**","/plugins/**/api/**","/api/file/upload").excludePathPatterns("/api/login", "/admin/**");

    }
}
